package cn.gov.escience.solr;

import javax.annotation.Resource;

import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;

import cn.gov.escience.prop.PropLoader;

@Configuration
@EnableSolrRepositories(basePackages = { "com.acme.solr" }, multicoreSupport = true)
public class SolrContext {

	private static String SOLR_HOST = PropLoader.getPathOf("SOLR_URL");

	@Resource
	private Environment environment;

	@Bean
	public SolrServer solrServer() {
		String solrHost = environment.getRequiredProperty(SOLR_HOST);
		return new HttpSolrServer(solrHost);
	}
}
